<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
<meta name="generator" content="Doxygen 1.9.1"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>Doxygen: mets::subject&lt; observed_subject &gt; 模板类 参考</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
<link href="navtree.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="resize.js"></script>
<script type="text/javascript" src="navtreedata.js"></script>
<script type="text/javascript" src="navtree.js"></script>
<link href="search/search.css" rel="stylesheet" type="text/css"/>
<script type="text/javascript" src="search/searchdata.js"></script>
<script type="text/javascript" src="search/search.js"></script>
<link href="doxygen.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
<div id="titlearea">
<table cellspacing="0" cellpadding="0">
 <tbody>
 <tr style="height: 56px;">
  <td id="projectalign" style="padding-left: 0.5em;">
   <div id="projectname">Doxygen
   </div>
  </td>
 </tr>
 </tbody>
</table>
</div>
<!-- end header part -->
<!-- 制作者 Doxygen 1.9.1 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
var searchBox = new SearchBox("searchBox", "search",false,'搜索','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(function() {
  initMenu('',true,false,'search.php','搜索');
  $(document).ready(function() { init_search(); });
});
/* @license-end */</script>
<div id="main-nav"></div>
</div><!-- top -->
<div id="side-nav" class="ui-resizable side-nav-resizable">
  <div id="nav-tree">
    <div id="nav-tree-contents">
      <div id="nav-sync" class="sync"></div>
    </div>
  </div>
  <div id="splitbar" style="-moz-user-select:none;" 
       class="ui-resizable-handle">
  </div>
</div>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
$(document).ready(function(){initNavTree('classmets_1_1subject.html',''); initResizable(); });
/* @license-end */
</script>
<div id="doc-content">
<!-- window showing the filter options -->
<div id="MSearchSelectWindow"
     onmouseover="return searchBox.OnSearchSelectShow()"
     onmouseout="return searchBox.OnSearchSelectHide()"
     onkeydown="return searchBox.OnSearchSelectKey(event)">
</div>

<!-- iframe showing the search results (closed by default) -->
<div id="MSearchResultsWindow">
<iframe src="javascript:void(0)" frameborder="0" 
        name="MSearchResults" id="MSearchResults">
</iframe>
</div>

<div class="header">
  <div class="summary">
<a href="#pub-methods">Public 成员函数</a> &#124;
<a href="#pro-attribs">Protected 属性</a> &#124;
<a href="classmets_1_1subject-members.html">所有成员列表</a>  </div>
  <div class="headertitle">
<div class="title">mets::subject&lt; observed_subject &gt; 模板类 参考</div>  </div>
</div><!--header-->
<div class="contents">

<p>template class for subjects (cfr. Observer Design Pattern).  
 <a href="classmets_1_1subject.html#details">更多...</a></p>

<p><code>#include &lt;<a class="el" href="observer_8hh_source.html">observer.hh</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public 成员函数</h2></td></tr>
<tr class="memitem:a580c481db07f883261c0a24f0f201067"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmets_1_1subject.html#a580c481db07f883261c0a24f0f201067">attach</a> (<a class="el" href="classmets_1_1observer.html">observer</a>&lt; observed_subject &gt; &amp;o)</td></tr>
<tr class="memdesc:a580c481db07f883261c0a24f0f201067"><td class="mdescLeft">&#160;</td><td class="mdescRight">Attach a new observer to this subject.  <a href="classmets_1_1subject.html#a580c481db07f883261c0a24f0f201067">更多...</a><br /></td></tr>
<tr class="separator:a580c481db07f883261c0a24f0f201067"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:af6b5055d74cb5671e46bb57a4109cf3a"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmets_1_1subject.html#af6b5055d74cb5671e46bb57a4109cf3a">detach</a> (<a class="el" href="classmets_1_1observer.html">observer</a>&lt; observed_subject &gt; &amp;o)</td></tr>
<tr class="memdesc:af6b5055d74cb5671e46bb57a4109cf3a"><td class="mdescLeft">&#160;</td><td class="mdescRight">Detach a new observer to this subject.  <a href="classmets_1_1subject.html#af6b5055d74cb5671e46bb57a4109cf3a">更多...</a><br /></td></tr>
<tr class="separator:af6b5055d74cb5671e46bb57a4109cf3a"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a604a3c6cb19a470779170e29528f3e83"><td class="memItemLeft" align="right" valign="top">virtual void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="classmets_1_1subject.html#a604a3c6cb19a470779170e29528f3e83">notify</a> ()</td></tr>
<tr class="memdesc:a604a3c6cb19a470779170e29528f3e83"><td class="mdescLeft">&#160;</td><td class="mdescRight">Notify all attached observers.  <a href="classmets_1_1subject.html#a604a3c6cb19a470779170e29528f3e83">更多...</a><br /></td></tr>
<tr class="separator:a604a3c6cb19a470779170e29528f3e83"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pro-attribs"></a>
Protected 属性</h2></td></tr>
<tr class="memitem:a01924f78859ce56ff0448030e81166e0"><td class="memItemLeft" align="right" valign="top"><a id="a01924f78859ce56ff0448030e81166e0"></a>
std::set&lt; <a class="el" href="classmets_1_1observer.html">observer</a>&lt; observed_subject &gt; * &gt;&#160;</td><td class="memItemRight" valign="bottom"><b>observers_m</b></td></tr>
<tr class="separator:a01924f78859ce56ff0448030e81166e0"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">详细描述</h2>
<div class="textblock"><h3>template&lt;typename observed_subject&gt;<br />
class mets::subject&lt; observed_subject &gt;</h3>

<p>template class for subjects (cfr. Observer Design Pattern). </p>
<p>You must declare the subject of the observations with:</p>
<p>class my_observed_sbj : public subject&lt;my_observed_sbj&gt;</p>
<p>Than you should call <a class="el" href="classmets_1_1subject.html#a604a3c6cb19a470779170e29528f3e83" title="Notify all attached observers.">notify()</a> manually or automatically from every method that changes the subject status.</p>
<p>Only attached observers (cfr. <a class="el" href="classmets_1_1subject.html#a580c481db07f883261c0a24f0f201067" title="Attach a new observer to this subject.">attach()</a> and <a class="el" href="classmets_1_1subject.html#af6b5055d74cb5671e46bb57a4109cf3a" title="Detach a new observer to this subject.">detach()</a> methods) will be notified. </p>
</div><h2 class="groupheader">成员函数说明</h2>
<a id="a580c481db07f883261c0a24f0f201067"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a580c481db07f883261c0a24f0f201067">&#9670;&nbsp;</a></span>attach()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename observed_subject &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classmets_1_1subject.html">mets::subject</a>&lt; observed_subject &gt;::attach </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classmets_1_1observer.html">observer</a>&lt; observed_subject&lt; observed_subject &gt; &gt; &amp;&#160;</td>
          <td class="paramname"><em>o</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Attach a new observer to this subject. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">o</td><td>a new observer for this subject. if the observer was already present nothing happens. </td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line"><a name="l00152"></a><span class="lineno">  152</span>&#160;  { observers_m.insert(&amp;o); }</div>
</div><!-- fragment -->
</div>
</div>
<a id="af6b5055d74cb5671e46bb57a4109cf3a"></a>
<h2 class="memtitle"><span class="permalink"><a href="#af6b5055d74cb5671e46bb57a4109cf3a">&#9670;&nbsp;</a></span>detach()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename observed_subject &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classmets_1_1subject.html">mets::subject</a>&lt; observed_subject &gt;::detach </td>
          <td>(</td>
          <td class="paramtype"><a class="el" href="classmets_1_1observer.html">observer</a>&lt; observed_subject&lt; observed_subject &gt; &gt; &amp;&#160;</td>
          <td class="paramname"><em>o</em></td><td>)</td>
          <td></td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Detach a new observer to this subject. </p>
<dl class="params"><dt>参数</dt><dd>
  <table class="params">
    <tr><td class="paramname">o</td><td>observer to detach from this subject. if the observer "o" was not present nothing happens. </td></tr>
  </table>
  </dd>
</dl>
<div class="fragment"><div class="line"><a name="l00157"></a><span class="lineno">  157</span>&#160;  { observers_m.erase(&amp;o); }</div>
</div><!-- fragment -->
</div>
</div>
<a id="a604a3c6cb19a470779170e29528f3e83"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a604a3c6cb19a470779170e29528f3e83">&#9670;&nbsp;</a></span>notify()</h2>

<div class="memitem">
<div class="memproto">
<div class="memtemplate">
template&lt;typename observed_subject &gt; </div>
<table class="mlabels">
  <tr>
  <td class="mlabels-left">
      <table class="memname">
        <tr>
          <td class="memname">void <a class="el" href="classmets_1_1subject.html">mets::subject</a>&lt; observed_subject &gt;::notify</td>
        </tr>
      </table>
  </td>
  <td class="mlabels-right">
<span class="mlabels"><span class="mlabel">virtual</span></span>  </td>
  </tr>
</table>
</div><div class="memdoc">

<p>Notify all attached observers. </p>
<p>When this method is called every observed_subject::update method is called and "this" subject is passed as a param. </p>
<div class="fragment"><div class="line"><a name="l00162"></a><span class="lineno">  162</span>&#160;  {</div>
<div class="line"><a name="l00163"></a><span class="lineno">  163</span>&#160;    <span class="comment">// upcast the object to the real observer_subject type</span></div>
<div class="line"><a name="l00164"></a><span class="lineno">  164</span>&#160;    observed_subject* real_subject = <span class="keyword">static_cast&lt;</span>observed_subject*<span class="keyword">&gt;</span>(<span class="keyword">this</span>);</div>
<div class="line"><a name="l00165"></a><span class="lineno">  165</span>&#160;    std::for_each(observers_m.begin(), observers_m.end(), </div>
<div class="line"><a name="l00166"></a><span class="lineno">  166</span>&#160;          update_observer&lt;observed_subject&gt;(real_subject));</div>
<div class="line"><a name="l00167"></a><span class="lineno">  167</span>&#160;  }</div>
</div><!-- fragment -->
</div>
</div>
<hr/>该类的文档由以下文件生成:<ul>
<li>recognition/include/pcl/recognition/3rdparty/metslib/<a class="el" href="observer_8hh_source.html">observer.hh</a></li>
</ul>
</div><!-- contents -->
</div><!-- doc-content -->
<!-- start footer part -->
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  <ul>
    <li class="navelem"><b>mets</b></li><li class="navelem"><a class="el" href="classmets_1_1subject.html">subject</a></li>
    <li class="footer">制作者 <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.1 </li>
  </ul>
</div>
</body>
</html>
